﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using static System.Net.Mime.MediaTypeNames;

namespace Aliphant.Common.Helper
{
    public static class DomainHelper
    {
        public static string GetCachePath(string file, string path)
        {
            string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "caches", path);
            string fileName = Convert.ToBase64String(Encoding.UTF8.GetBytes(file)).Replace("/", "_") + ".dat";
            string filePath = Path.Combine(dir, fileName);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            return filePath;
        }

        public static string GetHistoryPath(string fileName, string path)
        {
            string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "history", path);
            string filePath = Path.Combine(dir, fileName);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            return filePath;
        }

        public static string GetConfigPath(string config = "settings")
        {
            string dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "configs");
            string filePath = Path.Combine(dir, config + ".json");
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            return filePath;
        }
    }
}
